package xyz.luxiaoxiang.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import xyz.luxiaoxiang.bean.HotQuestion;

import java.util.List;

/**
 * @author luxx
 */
public interface HotQuestionDao extends JpaRepository<HotQuestion, Integer> {

    /**
     * 根据子主题获取所有热门问答
     *
     * @param childTopicId
     * @return
     */
    List<HotQuestion> findAllByChildTopicId(int childTopicId);

    /**
     * 根据关键词查找内容
     * @param keyword
     * @return
     */
    //@Query(value="select * from hot_quesion where excerpt like ?1",nativeQuery = true)
    List<HotQuestion> findByExcerptLike(String keyword);

    /**
     * 根据关键词查找问题名
     * @param keyword
     * @return
     */
    List<HotQuestion> findByQuestionNameLike(String keyword);

    HotQuestion findByAnswerId(int answerId);
}
